package org.r.items.tally.consumer.service.impl;

import org.apache.dubbo.config.annotation.DubboReference;
import org.r.items.tally.consumer.api.user.TallyUserDetailsRemote;
import org.r.items.tally.consumer.dto.UserInfo;
import org.r.items.tally.consumer.service.UserInfoService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Service
public class UserInfoServiceImpl implements UserInfoService {

    @DubboReference
    private TallyUserDetailsRemote tallyUserDetailsRemote;


    @Override
    @Cacheable(value = "user_info::user_name", key = "#username")
    public UserInfo getUserInfoByName(String username) {
        return tallyUserDetailsRemote.getUserInfoByName(username);
    }

    @Override
    @Cacheable(value = "user_info::cell_phone_num", key = "#cellPhoneNum")
    public UserInfo getUserInfoByCellPhoneNum(String cellPhoneNum) {
        return tallyUserDetailsRemote.getUserInfoByCellPhoneNum(cellPhoneNum);
    }

    @Override
    @Cacheable(value = "user_info::email", key = "#email")
    public UserInfo getUserInfoByEmail(String email) {
        return tallyUserDetailsRemote.getUserInfoByEmail(email);
    }
}
